#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main()
{
    umask(0);
    int fd = open("log.txt",O_RDONLY,0666);

    char buff[1025];
    read(fd,buff,1024);
    buff[1024] = 0;
    printf("%s",buff);

    //int fd = open("log.txt",O_CREAT | O_TRUNC | O_WRONLY,0666);

    //const char* ptr = "hello quitesix\n";
    //size_t len = strlen(ptr);
    //int cnt = 5;
    //while(cnt--)
    //{
    //    write(fd,ptr,len);
    //}
    int ret = close(fd);
    if(ret==-1)
    {
        perror("close");
        return 1;
    }

    return 0;
}
